#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1000010;
int cnt[N], a[N], s[N];
int n;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 1; i < N; i++)
    {
        for (int j = i; j < N; j += i)
        {
            s[j] += cnt[i];
        }
    }
    for (int i = 0; i < n; i++) cout << s[a[i]] - 1 << endl;
    return 0;
}